//
//  StroeMoneyViewController.m
//  WGFGlobalHouses
//
//  Created by waiguofang on 15/4/29.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//  门店佣金

#import "StroeMoneyViewController.h"
#import "PersonalMoneyCell.h"
#import "StoreMoneyCell.h"
#import "MoneyDetail.h"
#import "MiddleManMoneyOfStoreTableViewCell.h"
@interface StroeMoneyViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UILabel *lab1;
@property (weak, nonatomic) IBOutlet UILabel *lab2;
@property (weak, nonatomic) IBOutlet UILabel *lab3;

@end

@implementation StroeMoneyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self addSearchRightItem];
    [self addTableView];
    [self addMoneyDetailView];
    
    
}
-(void)addMoneyDetailView
{
    MoneyDetail *moneyDetailView = [MoneyDetail initWithXib];
    moneyDetailView.frame = CGRectMake(0, 66, UIScreenWidth, 88);
    [self.view addSubview:moneyDetailView];
}

-(void)viewWillAppear:(BOOL)animated
{
    
    [super viewWillAppear:YES];
    [self setNavigationTitle];
    [self setLabs];
}
#pragma mark 设置lab1,lab2,lab3
-(void)setLabs
{
    if (self.viewFlag == isStoreMoneyView)
    {
        self.lab1.text = @"门店名称";
        self.lab3.text = @"佣金";
        self.lab2.hidden = YES;
    }else if(self.viewFlag == isMiddleManMoneyOfStoreView || self.viewFlag == isMiddleManMoneyView)
    {
        self.lab1.text = @"经纪人";
        self.lab2.hidden = YES;
        self.lab3.text = @"佣金";
    }else
    {
        self.lab1.text = @"佣金比例(%)";
        self.lab2.hidden = NO;
        self.lab2.text = @"预计佣金(美元)";
        self.lab3.text = @"实际佣金(美元)";
    }
}

#pragma  mark 响应导航栏右侧的查询按钮
-(void)clickSearchItem
{
    
    if (!self.showSearchView)
    {
        [self showSearhRightItemView];
    }
    else
    {
        [self hiddenSearchView];
    }
    
    
}

#pragma mark 设置导航栏的标题
-(void)setNavigationTitle
{
    }
-(void)addTableView
{
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 203, UIScreenWidth, UIScreenHeight - 203) style:UITableViewStylePlain];
    [self.view addSubview:self.tableView];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    if (self.viewFlag == isPersonalMoneyView)
    {
        self.tableView.allowsSelection = NO;
    }
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    return 10;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.viewFlag == isStoreMoneyView)
    {
        return [StoreMoneyCell cellWithTableView:tableView];
    }
    else if (self.viewFlag == isMiddleManMoneyOfStoreView || self.viewFlag == isMiddleManMoneyView)
    {
        return [MiddleManMoneyOfStoreTableViewCell cellWithTableView:tableView];
    }
    else
    {
        return [PersonalMoneyCell cellWithTableView:tableView];
    }
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
    if (self.viewFlag != isPersonalMoneyView)
    {
        return 44;
    }
    else
    {
        return 145;
    }

}



-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
  StroeMoneyViewController *vc = [[StroeMoneyViewController alloc]initWithNibName:@"StroeMoneyViewController" bundle:nil];
    if (self.viewFlag == isStoreMoneyView) //当前是门店佣金
    {
        vc.viewFlag = isMiddleManMoneyOfStoreView;//门店下的经纪人佣金页面
    }else if (self.viewFlag == isMiddleManMoneyOfStoreView)
    {
        vc.viewFlag = isPersonalMoneyView; //个人佣金页面
    }else if (self.viewFlag == isMiddleManMoneyView)
    {
        vc.viewFlag = isPersonalMoneyView;
    }
    
    [self.navigationController pushViewController:vc animated:YES];
 }
@end
